#module load mvapich-intel
#module load fftw/3.3.1/mvapich-intel


# name of executables
NLS	= nls.x
TST	= test.x

#List of sources
C_NLS	= main.c init.c io.c arrays.c ic_s.c timers.c ffts.c split_step.c
C_TST   = test.c

# Compilers
CC	= mpicc
LINK	= mpicc
OPT	= -g3 -O2

#-----------------------------
#generic

LIB_MPI		= 
LIB_FFT		= -lfftw3_mpi -lfftw3 -lm
INC_MPI		= 
INC_FFT		=
LIB_ADD		= 

ifeq ($(HOSTNAME), pequena)
	LIB_MPI 	= 
	LIB_FFT		= -lfftw3_mpi -lfftw3 -lm
	INC_MPI		=
	INC_FFT		=
endif
ifeq ($(HOSTNAME), metropolis.RR)
        LIB_MPI         =
        LIB_FFT         = -L/opt/local/fftw/3.3.1/mvapich2/1.7/intel/12.1/lib -lfftw3_mpi -lfftw3 -lm
        INC_MPI         =
        INC_FFT         =
endif
ifeq ($(HOSTNAME), machina)
	LIB_MPI		=
	LIB_FFT		= -lfftw3_mpi -lfftw3 -lm
	INC_MPI		=
	INC_FFT		=
endif

#-----------------------------

OBJ_NLS		= $(C_NLS:.c=.o) $(F_NLS:.f=.o)
OBJ_TST		= $(C_TST:.c=.o) $(F_TST:.f=.o)

LIB_NLS		= $(LIB_MPI) $(LIB_FFT) $(LIB_ADD)
INC_NLS		= $(INC_MPI) $(INC_FFT)
#-----------------------------

default: nls

.f.o:
	$(FC) $(FFLAGS) -c $<


nls:
	$(CC) $(OPT) $(DEF_NLS) $(INC_NLS) -c $(C_NLS)
	$(LINK) $(OPT) $(OBJ_NLS) $(LIB_NLS) -o $(NLS)

test:
	$(CC) $(OPT) $(DEF_NLS) $(INC_NLS) -c $(C_TST)
	$(LINK) $(OPT) $(OBJ_TST) $(LIB_NLS) -o $(TST)

hostname:
	@echo $(HOSTNAME) $(INC_FFT)

clean:
	@echo "cleaning ..."
	rm -f *~ *.o

#-------------------------------
